import { Metadata } from "next";
import { getRecommendedPosts } from "./actions";
import PostSummaryList from "@/components/post-summary-list";
import ErrorInfo from "@/components/error-info";

export const metadata: Metadata = {
  title: "Posts",
};

export default async function Page() {
  const recommendedPosts = await getRecommendedPosts();
  if (recommendedPosts.ok) {
    return <PostSummaryList posts={recommendedPosts.data} />;
  } else {
    return <ErrorInfo code={recommendedPosts.code} message={recommendedPosts.message} />;
  }
}
